package com.cysion.study.ui

import com.cysion.study.ktbox.base.BaseActivity
import com.cysion.study.ktbox.net.BaseResponseRx
import com.cysion.study.ktbox.net.ErrorHandler
import com.cysion.study.ktbox.utils.darkTextTheme
import com.cysion.other.color
import com.cysion.targetfun._subscribe
import com.cysion.study.uibox.dialog.Alert
import com.cysion.study.R
import com.cysion.study.customview.java.SimpleData
import com.cysion.study.helper.UserCache
import com.cysion.study.net.ApiClient
import com.cysion.study.widget.ShowToast
import kotlinx.android.synthetic.main.activity_call_roll.*


//学生点名
class CallRollActivity : BaseActivity() {

    var simpleDatas: MutableList<SimpleData.Students> = mutableListOf()
    override fun getLayoutId(): Int = R.layout.activity_call_roll
    private var caid=""
    override fun initView() {
        caid = intent.extras.getString("caid")
        darkTextTheme(color(R.color.white))
        iv_back.setOnClickListener {
            finish()
        }



       /* simpleAdaper.setOnItemClicks {position, entity ->
            //flag 1 签到
            sendSign(position,entity)
        }*/
    }


    override fun initData() {
        super.initData()
        getDataList()
    }

    private fun getDataList() {
        //isSign 是否签到 -1.全部 0.已签到 1.未签到
        ApiClient.api.classesGetByClid(UserCache.token,caid,"-1")
            .compose(BaseResponseRx.validateToMain())
            ._subscribe {
                _onNext {
                    Alert.close()
                    bean = it
                    inView(it)

                }
                _onError {
                    Alert.close()
                    ShowToast(ErrorHandler.handle(it).errorMsg)
                }
            }
    }

    lateinit var bean:SimpleData
    private fun inView(it: SimpleData) {
      /*  simpleDatas = it.students
        simpleAdaper.setDatas(simpleDatas)
        CLog.e("@@@="+simpleDatas.size)
        simpleAdaper.notifyDataSetChanged()
        tv_title.text=it.courseName
        tv_time.text=it.startTime
        tv_signin.text="应到"+it.entityNum+"人    实到"+it.signNum+"人"
        tv_address.text=it.address
        //status":0//班级状态 0.未开始 1.授课中 2.授课完成 3.取消授课
        if (it.status == "0") {
            tv_status.text = "未开始"
        } else if (it.status == "1") {
            tv_status.text = "授课中"
        } else if (it.status == "2") {
            tv_status.text = "授课完成"
        } else if (it.status == "3") {
            tv_status.text = "取消授课"
        }*/
    }










    override fun closeMvp() {
    }


}
